import {reqBanner,reqSongList,reqPlayList,reqNewSong,reqAblumList} from "@/api/home.js"
 
export default {
    state: {
        bannerList: [],
        songList:[],
        playList:[],
        newSongList:[],
        ablumList:[]
    },

    getters: {

    },

    actions:{
        async getBanner({commit}) {
            const bannerList = await reqBanner()
            commit("GET_BANNER",bannerList)
        },

        async getSongList({commit}) {
            const songList = await reqSongList()
            commit("GET_SONG_LIST",songList)
        },

        async getPlayList({commit}) {
            const playList = await reqPlayList()
            commit("GET_PLAY_LIST",playList)
        },

        async getNewSong({commit}) {
            const newSongLists = await reqNewSong()
            const newSongList = newSongLists.result.slice(0,6)
            commit("GET_NEW_SONG",newSongList)
        },

        async getAblumList({commit}) {
            const ablumLists = await reqAblumList()
            const ablumList = ablumLists.monthData.slice(0,50)
            commit("GET_ABLUM_LIST",ablumList)
        }
    },

    mutations:{
        GET_BANNER(state,bannerList){
            state.bannerList = bannerList
        },

        GET_SONG_LIST(state,songList){
            state.songList = songList
        },

        GET_PLAY_LIST(state,playList){
            state.playList = playList
        },

        GET_NEW_SONG(state,newSongList){
            state.newSongList = newSongList
        },

        GET_ABLUM_LIST(state,ablumList){
            state.ablumList = ablumList
        },
    }
}